﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Common;

namespace SYH.Product.BLL
{
    public class Industry
    {
        private static readonly SYH.Product.DAL.Industry dal = new DAL.Industry();
        /// <summary>
        /// 根据ParentId获取列表
        /// </summary>
        /// <returns></returns>
        public static List<SYH.Product.Model.PublicIndustries> GetIndustriesList(int parentId)
        {
            DataTable dt = SYH.Product.DAL.Industry.GetIndustriesList(parentId);
            return Common.ModelHelper.FillModelsFromDataTable<SYH.Product.Model.PublicIndustries>(dt);
        }
        public static DataTable GetList(int parentId)
        {
            return SYH.Product.DAL.Industry.GetIndustriesList(parentId);
        }

        /// <summary>
        /// 得到用户产品三级行业名称
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <param name="top">记录数</param>
        /// <returns></returns>
        public static DataTable GetUserIndustries3Name(int userid, int top)
        {
            string key = "GetUserIndustries3Name_" + userid;
            DataTable dt = Common.DotNetCacheManager.Get(key) as DataTable;// QiHuiWang.Cache.DNTCacheManager.Current.Get(key) as DataTable;
            if (dt == null)
            {
                dt = dal.GetUserIndustries3Name(userid, top).Tables[0];
                Common.DotNetCacheManager.Add(key, dt, 60 * 48);
                //QiHuiWang.Cache.DNTCacheManager.Current.Add(key, dt, 60 * 48);
            }
            return dt;
        }
    }
}
